<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 求1~100之间所有数的平均值
        var sum = 0;
        var counter = 0;
        for (var i = 0; i < 101; i++) {
            sum += i;
            counter++;
        }
        console.log(sum,sum / counter);
        
        // 求1~100之间所有奇数和偶数的和
        var evenSum = 0;
        var oddSum = 0;
        for (var i = 2; i <= 100; i += 2) {
            evenSum += i;
        }
        console.log(evenSum);
        for (var i = 1; i <= 100; i += 2) {
            oddSum += i;
        }
        console.log(oddSum);

        // 求1~100之间所有奇数和偶数的和
        var evenSum = 0;
        var oddSum = 0;
        for (var i = 1; i <= 100; i++) {
            if (i % 2 === 1) {
                oddSum = oddSum + i;
            } else {
                evenSum = evenSum + i;
            }   
        }
        console.log('偶数和是' + evenSum,'奇数和是' + oddSum);
        
        // 求1~100之间所有能被3整除的数字的和和平均值
        var sum = 0;
        var a = 0;
        for (var i = 1; i <= 100; i++) {
            if (i % 3 === 0) {
                sum += i;
                a++;
            } 
        }
        console.log(sum,sum / a);

    </script>
</body>
</html>